package tr.gov.tubitak.bilgem.esya.certselector;

import tr.gov.tubitak.uekae.esya.api.common.util.bag.Pair;
import tr.gov.tubitak.uekae.esya.api.smartcard.pkcs11.BaseSmartCard;
import tr.gov.tubitak.uekae.esya.api.smartcard.pkcs11.CardType;

import javax.swing.*;
import java.awt.*;
import java.util.Locale;

public class TestCertSelection {
    private TestCertSelection(){};

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                createView();
            }
        });
    }

    private static void createView()
    {
        Locale.setDefault(Locale.ENGLISH);
        ECertTreePinPanel certTreePinPanel = new ECertTreePinPanel(true);
        JDialog dlg = new JDialog((Dialog) null);
        dlg.setContentPane(certTreePinPanel);
        dlg.setSize(400,500);
        //dlg.pack();
        dlg.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
        dlg.setVisible(true);
        String pin = certTreePinPanel.getPin();
        Pair<ReaderInfo,CertInfo> selectionInfo = certTreePinPanel.getSelectionInfo();
        if(selectionInfo!=null){
            ReaderInfo first = selectionInfo.first();
            if(first!=null){
                EBasicSmartCard basicSmartCard = first.getBasicSmartCard();
                BaseSmartCard baseSmartCard = basicSmartCard.getBaseSmartCard();
                long l = first.getmSlotNo();
                CardType cardType = first.getmCardType();
            }
        }

    }

}